﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using ShapeDemo.UC.WinProp;
using System.Windows;
using System.Windows.Input;

namespace ShapeDemo
{
    public class PointDrawer
    {
        private Canvas pointCanvas;
        private List<ASPNETX_WPFPoint> lstPoint;
        private WinPropPoint winPointProp;
        private WinPropCommon winCommonProp;

        ASPNETX_WPFPoint pointBody;
        TMouse MouseType;

        public PointDrawer(Canvas canvasContent, List<ASPNETX_WPFPoint> lstShape, WinPropPoint winShapeProp,WinPropCommon winProp)
        {
            pointCanvas = canvasContent;
            lstPoint = lstShape;
            winPointProp = winShapeProp;
            winCommonProp = winProp;

            MouseType = TMouse.Drawing;

            pointCanvas.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(pointCanvas_MouseLeftButtonDown);
            pointCanvas.MouseMove += new System.Windows.Input.MouseEventHandler(pointCanvas_MouseMove);
            
        }

        public void Draw()
        { 
            
        }

        
        #region 画点
        private void pointCanvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (MouseType == TMouse.Drawing)
            {
                Point p = e.GetPosition(pointCanvas);

                pointBody = new ASPNETX_WPFPoint();

                pointBody.CommonProperty.Index = winCommonProp.tbIndex.Text;
                pointBody.CommonProperty.Content = winCommonProp.tbContent.Text;

                pointBody.PointBody = p;
                pointCanvas.Children.Add(pointBody.DrawPoint());

                lstPoint.Add(pointBody);

                //BindListBox();
            }
        }

        private void pointCanvas_MouseMove(object sender, MouseEventArgs e)
        {
            if (MouseType == TMouse.Drawing)
            {
                Point p = e.GetPosition(pointCanvas);
                winPointProp.X = p.X;
                winPointProp.Y = p.Y;
            }
        }
        #endregion
    }
}
